package com.alibaba.ai.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.ai.entity.YPost;
import com.alibaba.ai.service.YPostService;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author 86188
 */
@Controller
public class YPostController {
    @Resource
    private YPostService YPostService;

    @ResponseBody
    @RequestMapping("/getPostListByWeek")
    public List<YPost> getPostListByWeek() {
        List<YPost> listPost = YPostService.getPostListByWeek();
        for (YPost YPost : listPost) {
            System.out.println(YPost);
        }
        return listPost;
    }

    @ResponseBody
    @RequestMapping("/getPostListByMonth")
    public List<YPost> getPostListByMonth() {
        List<YPost> listPost = YPostService.getPostListByMonth();
        for (YPost YPost : listPost) {
            System.out.println(YPost);
        }
        return listPost;
    }

    //个人信息页面————通过id查询 论坛 帖子 发布日期
    @ResponseBody
    @RequestMapping("/getPostListByUserId")
    public List<YPost> getPostListByUserId(Integer yUsersId) {
        List<YPost> listPost = YPostService.getPostListByUserId(yUsersId);
        for (YPost YPost : listPost) {
            System.out.println(YPost);
        }
        return listPost;
    }

    //模糊查询操作————精华帖和业主论坛两个页面的搜索模块
    @ResponseBody
    @RequestMapping("/getPostlistByTitle")
    public List<JSONObject> getPostlistByTitle(String yPostTitle) {
        List<JSONObject> listPost = YPostService.getPostlistByTitle(yPostTitle);
        for (JSONObject YPost : listPost) {
            System.out.println(YPost);
        }
        return listPost;
    }

}